package cn.train.controler;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.train.model.UserTable;
import cn.train.service.UserTableService;


@WebServlet("/RegServlet")
public class RegServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String uname = req.getParameter("UserName");
		String upass = req.getParameter("Pass");
		String findpwd = req.getParameter("MiBao");
		String phonenum = req.getParameter("PhoneNumber");
		String realname = req.getParameter("TName");
		String idcard = req.getParameter("IDCard");
		UserTableService userService=new UserTableService();
		UserTable usertable=new UserTable();
		usertable.setUname(uname);
		usertable.setUpass(upass);
		usertable.setFindpwd(findpwd);
		usertable.setPhonenum(phonenum);
		usertable.setRealname(realname);
		usertable.setIdcard(idcard);
		boolean flag=userService.addUser(usertable);
		if(flag) {
//			req.getRequestDispatcher("font/login.jsp").forward(req, resp);
			resp.sendRedirect("font/login.jsp");
		}
	}
	
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req,resp);
	}

}
